package com.ougy.reshop.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.search.annotations.Analyzer;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.search.annotations.Store;

import com.chenlb.mmseg4j.analysis.MaxWordAnalyzer;

@Entity
@Analyzer(impl=MaxWordAnalyzer.class)
@Indexed
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
public class Publish {
	private String id;
	private int type;
	private String title;
	private double price;
	private String descContent;
	private GoodsClass pubGoodClass;
	private Album showImage;
	private PlaceInfo placeInfo;
	private Region twoLevel;
	private Region threeLevel;
	private String telPhone;
	private String qq;
	private String linkmanName;
	private int state;
	private User owner;
	private Date createTime;
	private Date updateTime;
	private int viewCount;

	@Id
	@DocumentId 
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}
	@Column(nullable=false)
	@Field(index=Index.TOKENIZED,store=Store.YES)  
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}
	
	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	@Column(columnDefinition = "LongText")
	public String getDescContent() {
		return descContent;
	}

	public void setDescContent(String descContent) {
		this.descContent = descContent;
	}

	@ManyToOne
	public GoodsClass getPubGoodClass() {
		return pubGoodClass;
	}

	public void setPubGoodClass(GoodsClass pubGoodClass) {
		this.pubGoodClass = pubGoodClass;
	}

	@OneToOne
	public Album getShowImage() {
		return showImage;
	}

	public void setShowImage(Album showImage) {
		this.showImage = showImage;
	}
	@Column(nullable=false)
	public String getTelPhone() {
		return telPhone;
	}

	public void setTelPhone(String telPhone) {
		this.telPhone = telPhone;
	}

	public String getQq() {
		return qq;
	}

	public void setQq(String qq) {
		this.qq = qq;
	}

	public String getLinkmanName() {
		return linkmanName;
	}

	public void setLinkmanName(String linkmanName) {
		this.linkmanName = linkmanName;
	}

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}

	@ManyToOne
	@IndexedEmbedded
	public User getOwner() {
		return owner;
	}

	public void setOwner(User owner) {
		this.owner = owner;
	}

	@OneToOne
	public PlaceInfo getPlaceInfo() {
		return placeInfo;
	}

	public void setPlaceInfo(PlaceInfo placeInfo) {
		this.placeInfo = placeInfo;
	}

	@ManyToOne
	public Region getTwoLevel() {
		return twoLevel;
	}

	public void setTwoLevel(Region twoLevel) {
		this.twoLevel = twoLevel;
	}

	@ManyToOne
	public Region getThreeLevel() {
		return threeLevel;
	}

	public void setThreeLevel(Region threeLevel) {
		this.threeLevel = threeLevel;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public int getViewCount() {
		return viewCount;
	}

	public void setViewCount(int viewCount) {
		this.viewCount = viewCount;
	}

}